package com.zhz.demothymeleaf.web.controller;

import com.zhz.demothymeleaf.entity.Dept;
import com.zhz.demothymeleaf.entity.User;
import com.zhz.demothymeleaf.service.DeptService;
import com.zhz.demothymeleaf.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @Resource
    private DeptService deptService;

    @GetMapping("/main")
    public String main(){
        return "index";
    }

    @GetMapping("users")
    public String userList(Model model){
        List<User> list = userService.getUserList();
        model.addAttribute("users",list);
        return "list";
    }
}
